home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C12 / Ambig.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  438 b   |  26 lines

  1. //: C12:Ambig.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Ambiguity in type conversion
  7.  
  8. class Y; // Class declaration
  9.  
  10. class X {
  11. public:
  12.   operator Y() const; // Convert X to Y
  13. };
  14.  
  15. class Y {
  16. public:
  17.   Y(X); // Convert X to Y
  18. };
  19.  
  20. void f(Y);
  21.  
  22. int main() {
  23.   X x;
  24. //! f(x); // Error: ambiguous conversion
  25. } ///:~
  26.